package net.lzzy.practices.web.models;

import net.lzzy.practices.entities.BaseEntity;
import net.lzzy.practices.entities.Option;
import net.lzzy.practices.entities.Result;

import java.util.Date;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;

/**
 *@author hzl on 2022/6/8.
 *Description:
 */
public class VmResult {
    private UUID id;
    private int what;
    private UUID qid;
    private int ordinal;
    private UUID sid;
    private String name;
    private String avatar;
    private List<UUID>optionIds;
    private List<UUID>answerIds;
    private Date commitTime;

    public VmResult(Result result){
        id=result.getId();
        what=result.what();
        qid=result.getQuestion().getId();
        ordinal=result.getQuestion().getOrdinal();
        sid=result.getStudent().getId();
        avatar=result.getStudent().getAvatar();
        name=result.getStudent().getNickName();
        optionIds=result.getOptions().stream().map(BaseEntity::getId).collect(Collectors.toList());
        answerIds=result.getQuestion().getOptions().stream().filter(Option::isAnswer).map(BaseEntity::getId).collect(Collectors.toList());

    }
}
